//
//  BCUnitTitleView.m
//  Memo
//
//  Created by 李雪 on 16/3/9.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.//

#import "BCUnitTitleView.h"

@implementation BCUnitTitleView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.eventCountLabel.hidden = NO;
        
        self.dayLabel.font = [UIFont boldSystemFontOfSize:15.0f];
        self.dayLabel.textColor = [UIColor colorWithRed:140/255. green:165/255. blue:240/255. alpha:1];
        self.dayLabel.layer.borderWidth = 2 ;
        self.dayLabel.layer.borderColor = [UIColor colorWithRed:255/255. green:228/255. blue:225/255. alpha:.8].CGColor;
        
        CGRect lunarLabelFrame = self.lunarLabel.frame;
        lunarLabelFrame.origin.y = self.bounds.size.height/5*4;
        lunarLabelFrame.size.height = self.bounds.size.height/5;
        self.lunarLabel.frame = lunarLabelFrame;
        
        self.lunarLabel.font = [UIFont systemFontOfSize:9.0f];
        self.lunarLabel.textColor = [UIColor blackColor];
        
        self.lunarLabel.hidden = NO;
    }
    return self;
}

- (void)updateUnitTileViewShowingWithOtherUnit:(BOOL)otherUnit Selected:(BOOL)selected Today:(BOOL)today eventsCount:(NSInteger)eventsCount
{
    self.backgroundColor=[UIColor clearColor];
    if (otherUnit) {
        self.dayLabel.textColor=[UIColor lightGrayColor];
        self.lunarLabel.textColor=[UIColor lightGrayColor];
    }else if(selected&&!today){
        // 当前日期 - 1
        self.dayLabel.textColor=[UIColor blackColor];
        self.dayLabel.textColor=[UIColor blackColor];
        self.backgroundColor=[UIColor greenColor];
    }else if (today){
        // 当前日期
        self.dayLabel.textColor=[UIColor blackColor];
        self.dayLabel.textColor=[UIColor blackColor];
        self.backgroundColor=[UIColor redColor];
        if (eventsCount) {
            self.eventCountLabel.text=[NSString stringWithFormat:@"%ld",eventsCount];
        }
    }else if (eventsCount){
        // 当前日期 记录 + 1
        self.backgroundColor=[UIColor yellowColor];
        self.eventCountLabel.text=[NSString stringWithFormat:@"%ld",eventsCount];
    }else{
        self.dayLabel.textColor=[UIColor blackColor];
        self.lunarLabel.textColor=[UIColor blackColor];
        self.eventCountLabel.text=nil;
    }
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
